<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">布拿拿合作方数据统计</ui:define>
    <ui:define name="content">
        <h:form>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix"
                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton value="刷新统计" icon="fa fa-refresh" update="@this"
                                         actionListener="#{collaborateBananaStatListBean.freshData()}"/>
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton value="重置" icon="fa fa-refresh" update="@form"
                                         actionListener="#{collaborateBananaStatListBean.onRest()}"/>
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         update="@form"/>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card ui-g-12">
                            <h1>查询条件</h1>

                            <div class="ui-g-1">
                                <p:outputLabel value="时间"/>
                            </div>
                            <div class="ui-g-2">
                                <p:calendar value="#{collaborateBananaStatListBean.$.startDate}"
                                            styleClass="autoWidthCalendar"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATE_FORMAT')}"
                                            readonlyInput="true"/>
                                <span>—</span>
                                <p:calendar value="#{collaborateBananaStatListBean.$.endDate}"
                                            styleClass="autoWidthCalendar"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATE_FORMAT')}"
                                            readonlyInput="true"/>
                            </div>

                            <div class="ui-g-1">
                                <p:outputLabel value="平台"/>
                            </div>
                            <div class="ui-g-2">
                                <p:selectOneMenu value="#{collaborateBananaStatListBean.$.platform}">
                                    <f:selectItem itemValue="" itemLabel="全部"/>
                                    <f:selectItem itemLabel="ios" itemValue="ios"/>
                                    <f:selectItem itemLabel="安卓" itemValue="android"/>
                                </p:selectOneMenu>
                            </div>

                            <div class="ui-g-1">
                                <p:outputLabel value="产品"/>
                            </div>
                            <div class="ui-g-2">
                                <p:selectOneMenu value="#{collaborateBananaStatListBean.$.productId}">
                                    <f:selectItem itemValue="" itemLabel="全部"/>
                                    <f:selectItem itemLabel="菠萝贷主包" itemValue="8000"/>
                                    <f:selectItem itemLabel="菠萝贷IOS" itemValue="8002"/>
                                </p:selectOneMenu>
                            </div>

                            <div class="ui-g-1">
                                <p:outputLabel value="渠道"/>
                            </div>
                            <div class="ui-g-2">
                                <p:selectOneMenu filter="true" filterMatchMode="startsWith"
                                                 value="#{collaborateBananaStatListBean.$.channelId}">
                                    <f:selectItem itemValue="" itemLabel="全部"/>
                                    <f:selectItems value="#{collaborateBananaStatListBean.currentUserChannelList}"
                                                   var="commProduct"
                                                   itemLabel="#{commProduct.channelName}"
                                                   itemValue="#{commProduct.channelCode}"/>
                                </p:selectOneMenu>
                            </div>

                            <div class="ui-g-1">
                                <p:outputLabel value="活动id"/>
                            </div>
                            <div class="ui-g-2">
                                <p:inputText value="#{collaborateBananaStatListBean.$.activityId}"/>
                            </div>

                        </div>
                        <div class="card ui-g-12">
                            <p:dataTable id="col-info-list"
                                         style="width: 100%;text-align: center"
                                         var="record"
                                         value="#{collaborateBananaStatListBean.lazyDataModel}"
                                         rows="#{constants:get('ROWS')}"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         reflow="true"
                                         resizableColumns="true">

                                <p:column headerText="日期">
                                    <h:outputText value="#{record.date}"/>
                                </p:column>
                                <p:column headerText="产品">
                                    <h:outputText value="#{collaborateBananaStatListBean.translateProduct(record.productId)}"/>
                                </p:column>
                                <p:column headerText="渠道">
                                    <h:outputText value="#{collaborateBananaStatListBean.translateProductChannel(record.channelId)}"/>
                                </p:column>
                                <p:column headerText="平台">
                                    <h:outputText value="#{record.platform}"/>
                                </p:column>
                                <p:column headerText="活动id">
                                    <h:outputText value="#{record.activityId}"/>
                                </p:column>
                                <p:column headerText="H5-登记人数"
                                          rendered="#{collaborateBananaStatListBean.showRegister()}">
                                    <h:outputText value="#{record.externalRegisterCount}"/>
                                </p:column>
                                <p:column headerText="H5-新注册数"
                                          rendered="#{collaborateBananaStatListBean.showNewRegister()}">
                                    <h:outputText value="#{record.externalNewRegisterCount}"/>
                                </p:column>
                                <p:column headerText="APP-注册人数（按设备）"
                                          rendered="#{collaborateBananaStatListBean.showAppCount()}">
                                    <h:outputText value="#{record.appActivateCount}"/>
                                </p:column>
                                <p:column headerText="APP-注册人数（按手机号）"
                                          rendered="#{collaborateBananaStatListBean.showAppCountPhone()}">
                                    <h:outputText value="#{record.appActivateCountPhone}"/>
                                </p:column>
                            </p:dataTable>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
